package com.qianfeng.openapi.search.controller;

import com.qianfeng.openapi.search.service.CustomerSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/search/customer")
public class CustomerSearchController {

    @Autowired
    private CustomerSearchService customerSearchService;

    @PostMapping(value = "/search",produces = "application/json;charset=utf-8")
    public String search(@RequestBody Map parameter) throws IOException {
        String json = customerSearchService.findCustomerByNickNameAndStateByPage(parameter);
        return json;
    }

    @PostMapping("/add")
    public void add(@RequestBody Map parameter) throws IOException {
        customerSearchService.add(parameter);
    }

}
